Grammar-based code
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
top
Grammar-based codes or grammar-based compression are compression algorithms based on the idea of constructing a context-free grammar (CFG) for the string to be compressed. Examples include universal lossless data compression algorithms.cite-ref-1[1] To compress a data sequence x = x 1 ⋯ ⋯ x n {\displaystyle x=x_{1}\cdots x_{n}} , a grammar-based code transforms x {\displaystyle x} into a context-free grammar G {\displaystyle G} . The problem of finding a smallest grammar for an input sequence (smallest grammar problem) is known to be NP-hard,cite-ref-2[2] so many grammar-transform algorithms are proposed from theoretical and practical viewpoints. Generally, the produced grammar G {\displaystyle G} is further compressed by statistical encoders like arithmetic coding.
Contents
• See also
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Examples and characteristics
The class of grammar-based codes is very broad. It includes block codes, the multilevel pattern matching (MPM) algorithm,cite-ref-3[3] variations of the incremental parsing Lempel-Ziv code,cite-ref-4[4] and many other new universal lossless compression algorithms. Grammar-based codes are universal in the sense that they can achieve asymptotically the entropy rate of any stationary, ergodic source with a finite alphabet.
Practical algorithms
The compression programs of the following are available from external links.
• GLZA,cite-ref-7[7] which constructs a grammar that may be reducible, i.e., contain repeats, where the entropy-coding cost of "spelling out" the repeats is less than the cost creating and entropy-coding a rule to capture them. (In general, the compression-optimal SLG is not irreducible, and the Smallest Grammar Problem is different from the actual SLG compression problem.)
See also
References
cite-note-77. ↑ citerefconradwilson2016Conrad, Kennon J.; Wilson, Paul R. (2016). "Grammatical Ziv-Lempel Compression: Achieving PPM-Class Text Compression Ratios with LZ-Class Decompression Speed". 2016 Data Compression Conference (DCC). p. 586. doi:10.1109/DCC.2016.119. ISBN 978-1-5090-1853-6. S2CID 3116024.
External links
• GLZA discussion and paper
• Description of grammar-based codes with example
• Sequitur codes Archived 2008-10-13 at the Wayback Machine
• Re-Pair codes
• Re-Pair codes a version of Gonzalo Navarro.
• GrammarViz 2.0 - implementation of Sequitur, Re-Pair, and parallel Re-Pair in Java.